<template>
  <div class="personal" v-show="init">
    <div class="item" @click="myCard">
      <div class="item-box">
        <div class="pic">
          <img src="~common/image/myCardPic.png" alt="">
        </div>
        <div class="text">
          <p class="title">我的名片</p>
          <p class="btn">点击进入 <i class="icon-xiangyou"></i></p>
        </div>
        <div class="amount">
          <i class="icon-business"></i>
          <span>{{card}}张</span>
        </div>
      </div>
    </div>
    <div class="item" @click="greeting">
      <div class="item-box">
        <div class="pic">
          <img src="~common/image/greeting.png" alt="">
        </div>
        <div class="text">
          <p class="title">贺卡</p>
          <p class="btn">点击进入 <i class="icon-xiangyou"></i></p>
        </div>
        <div class="amount">
          <i class="icon-business"></i>
          <span>{{imgs_total.bcard_total}}张</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {islogin, isTourist} from 'common/js/user'
  import {cardTotal} from 'common/js/greeting'
  import {setTitle} from 'common/js/title'
  import {computePV} from 'common/js/statistics'

  export default {
    data() {
      return {
        init: false,
        imgs_total: '',
        tourist: -1,
        card: 1

      }
    },
    mounted() {
      setTitle('个人中心')
      computePV({
        page_type:1
      })
      isTourist().then(res => {
        if (res.status === 1) {
          this.tourist = res.data;
          if (res.data !== 1 && res.data !== 2) {
            this.$router.push('/login');
          } else {
            this.init = true;
            if (res.data === 2) {
              this.card = 0;
            }
          }
        }
      })
      cardTotal().then(res => {
        if (res.status === 1) {
          this.imgs_total = res.data;
        }
      })
    },
    methods: {
      //进入我的名片
      myCard() {
        if(this.tourist === 1){
          this.$router.push('/business/' + this.imgs_total.card_id);
        }else{
          this.$router.push('/login');
        }
      },
      //跳转到照片墙
      photoall() {
        this.$router.push('/photoWall');
      },
      //进入我的贺卡
      greeting() {
        this.$router.push('/greeting');
      }
    }
  }
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
  @import "~common/stylus/variable"
  .personal
    min-height: 100%;
    background: #f65ecb;
    background: -webkit-linear-gradient(-300deg, #f65ecb, #9366f1);
    padding: .5rem;
    .item
      position: relative;
      height: 7.13rem;
      margin-bottom: .6rem;
      border: 2px solid rgba(255, 255, 255, .5);
      border-radius: .26rem;
      background: $background-p-i;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: wrap;
      .pic
        width: 100%;
        text-align: center;
      img
        width: 2.58rem;
        height: 2.58rem;
      .text
        color: $color;
        .title
          font-size: .62rem;
          margin-bottom: .5rem;
          text-align: center;
          margin-top: .57rem;
        .btn
          width: 2.56rem;
          line-height: .73rem;
          border-radius: .365rem;
          padding-left: .52rem;
          background: $background-p-btn;
          font-size: .32rem;
          i
            font-size: .27rem;
      .amount
        position: absolute;
        top: .47rem;
        right: .47rem;
        color: $color;
        font-size: .3rem;

</style>
